using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;

namespace Sec_scan漏洞扫描系统.Sec_Service
{
    /// <summary>
    /// 独立并发服务
    /// </summary>
    public class Sec_IndepenDent_Concurrency_Service
    {
        /// <summary>
        /// GET请求方法
        /// </summary>
        /// <param name="independent"></param>
        /// <returns></returns>
        public static string IndepenDent_Service(string independent)
        {
            Sec_Api.Sec_IndepenDent_Concurrency_Service_Api.ExpOptions = new StringBuilder();//实例化接口
            Sec_Api.Sec_IndepenDent_Concurrency_Service_Api.StatusOpen = new StringBuilder();
            string url = Sec_Api.Sec_IndepenDent_Concurrency_Service_Api.Url.ToString();
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                var status = response;
                if (status.StatusCode == HttpStatusCode.OK)
                {
                    //能打开的情况下
                    string open = "创建时间：" + DateTime.Now + "   -------   " + "访问成功，请查看访问时间！" + "\r\n";
                    Sec_Api.Sec_IndepenDent_Concurrency_Service_Api.StatusOpen.Append(open);
                }
            }
            catch(Exception ex)
            {
                //将错误信息进行传出
                Sec_Api.Sec_IndepenDent_Concurrency_Service_Api.ExpOptions.Append(ex.ToString());
            }
            return independent;
        }
    }
}
